/*
 * test_utils.c
 *
 *  Created on: Aug 12, 2012
 *      Author: tiberius
 */


#include "test_utils.h"
#include "basic_rx_tx_test.h"
#include "dev_dsp_test.h"
//#include "pack_unpack_test.h"
#include "pre_proc_test.h"

void fxp_to_float(int16_t* fxp, float* flt, int length) {
	int i;
	for (i = 0; i < length; i++) {

	}
}

void fxp_to_file(int16_t* fxp, int length, const char* fname) {
	FILE* fn = fopen(fname, "w");
	int i;
	for (i = 0; i < length; i++) {
		fprintf(fn, "%d\n", fxp[i]);
	}
	fclose(fn);
}

void float_to_file(float* flt, int length, const char* fname) {
	FILE* fn = fopen(fname, "w");
	int i;
	for (i = 0; i < length; i++) {
		fprintf(fn, "%f\n", flt[i]);
	}
	fclose(fn);
}

void file_to_fxp(const char* fname, int16_t* fxp, int length) {
	FILE* fn = fopen(fname, "w");
	int i;
	for (i = 0; i < length; i++) {
		fprintf(fn, "%d\n", fxp[i]);
	}
	fclose(fn);
}

void file_to_flt(const char* fname, float* flt, int length) {

}


// Run test method
void run_test(const char* tname) {
	if(strcmp(tname,"basic_rx_tx_test")==0) {
		basic_rx_tx_test();
	}
	if(strcmp(tname,"dev_dsp_test")==0) {
		dev_dsp_test();
	}
	if(strcmp(tname,"pack_unpack_test")==0) {
//		pack_unpack_test();
	}
	if(strcmp(tname,"pre_proc_test")==0) {
		pre_proc_test();
	}
}

// main method
int main(int argc, char** argv) {
	if(argc>1)
		run_test(argv[1]);
	else
		run_test("dev_dsp_test");
	return 0;
}




